import { request } from "@/utils/http";
import {
  getHospitalListParamsType,
  hospitalListReqReturnType,
  getProvinceListItemType,
  hospitalDetailType,
  hospitalDepartmentReturnType,
  getHospitalScheduleParamsType,
  getHospitalScheduleReturnType,
  findScheduleListType,
} from "./model/hospitalListTypes";

export const getHospitalListRequest = (
  page: number,
  limit: number,
  search?: getHospitalListParamsType
) => {
  return request.get<any, hospitalListReqReturnType>(
    `/admin/hosp/hospital/${page}/${limit}`,{
      params:search
    }
  );
};

export const getProvinceListRequest = () => {
  return request.get<any, getProvinceListItemType>(
    "/admin/cmn/dict/findByDictCode/province"
  );
};

export const getCityListRequest = (value: string) => {
  return request.get<any, getProvinceListItemType>(`/admin/cmn/dict/findByParentId/${value}`);
};

export const getHospitalDetailRequest=(id:string)=>{
  return request.get<any,hospitalDetailType>(`/admin/hosp/hospital/show/${id}`)
}

export const changeStatusRequest=(id:string,status:0|1)=>{
  return request.get<any,null>(`/admin/hosp/hospital/updateStatus/${id}/${status}`)
}

export const getHospitalDepartmentListRequest=(hoscode:string)=>{
  return request.get<any,hospitalDepartmentReturnType>(`/admin/hosp/department/${hoscode}`)
}

export const getHospitalScheduleListRequest=({page,limit,hoscode,depcode}:getHospitalScheduleParamsType)=>{
  return request.get<any,getHospitalScheduleReturnType>(`/admin/hosp/schedule/getScheduleRule/${page}/${limit}/${hoscode}/${depcode}`)
}

export const findScheduleListRequest=(hoscode:string,depcode:string,workDate:string)=>{
  return request.get<any,findScheduleListType>(`/admin/hosp/schedule/findScheduleList/${hoscode}/${depcode}/${workDate}
  `)
}